//
//  MerchantHotSearchCell.m
//  SearchView
//
//  Created by chenshan on 2016/9/28.
//  Copyright © 2016年 Owen.kang. All rights reserved.
//

#import "MerchantHotSearchCell.h"

@interface MerchantHotSearchCell ()

@property (nonatomic, strong) UIView *lineView;

@end

@implementation MerchantHotSearchCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:(self.leftButton = [self searchButton])];
        [self.contentView addSubview:(self.middleButton = [self searchButton])];
        [self.contentView addSubview:(self.rightButton = [self searchButton])];
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    CGFloat width = (CGRectGetWidth(self.bounds) - 2 * kMerchantSearchCellPadding) /3;
    self.leftButton.frame = CGRectMake(kMerchantSearchCellPadding, 0, width, CGRectGetHeight(self.bounds));
    self.middleButton.frame = CGRectMake(width + kMerchantSearchCellPadding, 0, width, CGRectGetHeight(self.bounds));
    self.rightButton.frame = CGRectMake(width * 2 + kMerchantSearchCellPadding, 0, width, CGRectGetHeight(self.bounds));
}

- (void)buttonDidTap:(UIButton *)sender {
    if([self.delegate respondsToSelector:@selector(hotSearchCellButtonDidClicked:)]) {
        [self.delegate hotSearchCellButtonDidClicked:sender];
    }
}

- (UIButton *)searchButton {
    UIButton *button = [[UIButton alloc] init];
    button.backgroundColor = [UIColor clearColor];
    [button addTarget:self action:@selector(buttonDidTap:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"袜子" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    
    return button;
}

@end
